package com.jcl.recruit.api.searchresume.controller;

import com.jcl.core.resp.ApiResponse;
import com.jcl.core.utils.StringUtils;
import com.jcl.recruit.core.constants.Constants;
import com.jcl.recruit.log.model.ResumeLog;
import com.jcl.recruit.resume.model.ResumeEvaluate;
import com.jcl.recruit.resume.service.ResumeEvaluateService;
import com.jcl.recruit.resume.service.ResumeOperateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName SearchResumeOperateController
 * @Description TODO
 * @Author yyliu
 * @Date 2018/9/30 9:15
 * @Version 1.0
 **/
@RestController
@RequestMapping("/api/searchresume")
public class SearchResumeOperateController {

    @Autowired
    private ResumeEvaluateService resumeEvaluateService;

    @Autowired
    private ResumeOperateService resumeOperateService;

    @RequestMapping("/evaluate/list/{id}")
    public ApiResponse listSearchEvaluate(@PathVariable Integer id){

        if(null == id){
            return ApiResponse.error(Constants.ReturnInfo.ERROR_PARAM_NULL_MSG);
        }

        List<ResumeEvaluate> list = resumeEvaluateService.getSearchDetailList(id);
        return ApiResponse.success(list);
    }

    @RequestMapping("/evaluate/add")
    public ApiResponse addSearchEvaluate(@RequestBody ResumeEvaluate evaluate){

        if(StringUtils.isEmpty(evaluate.getContent())){
            return ApiResponse.error("评价内容不能为空！");
        }

        resumeEvaluateService.addResumeEvaluate(evaluate, 0);

        return ApiResponse.success(Constants.ReturnInfo.SUCCESS_MSG);
    }

    @RequestMapping("/operate/list/{id}")
    public ApiResponse logSearchList(@PathVariable Integer id){

        if(null == id){
            return ApiResponse.error(Constants.ReturnInfo.ERROR_PARAM_NULL_MSG);
        }

        List<ResumeLog> list = resumeOperateService.findSearchList(id);

        return ApiResponse.success(list);
    }
}
